Snippets
Are a part of LazyScript Plugin Toggle toggle(name,control) name - represents a name for your toggle, wich allows multiple toggles control - ment for key controls, it needs a numeric input of 0 or 1 Examples: toggle("piston1", key("space") ) toggle("piston1") #with no control input it will only return the "piston1" toggle value toggle("silodoor", key("up") ) Jump Combine it with thrusters for easy jump mechanics. jump(name,control,delay,frame) name - represents a name for your jump, wich allows multiple seperate jumping controls control - ment for key controls, it needs a numeric input of 0 or 1 delay - delay before next jump, number of frames frame - just the SP standard frame variable Examples: jump("sheep", key("up"), 100, frame) jump("sheep") #if you specify only the name it will just return "sheep" jump value jump("cat", key("a"), 200, frame) Emit It does the same thing SP standard emiter does, only allows more control. emit(position,push_force,lifetime,object) potision - a 3D point where you want the emited object to popup push_force - with howmuch power you want to push the emited object lifetime - howlong you want the emited object to stay object - the entity you want to emit - and it returns the handle to the entity it created Examples: position=0,0,0 object=Sketchup.active_model.entities1 #an entity in model emit(position, 100, 500, object) #this will emit our entity to position 0,0,0 with a force of 100 and it will be active for 500 frames emit(10,0,0, 100, 500) #with no object specified it will just take the current one emit(1,1,1) #and no force or lifetime are needed either new_o=emit(1,1,10) #we get the handle for the new object new_o.material="red" #and not that we have the handle we can manipulate it(change its color to red) Kick This allows to push/kick any object in the model without setting up thrusters kick(push_force, object) push_force - with howmuch power you want to push the object object - the entity you want to push object=Sketchup.active_model.entities1 #an entity in model kick(100, object) kick(100) #when no object is specified it will push the current one Move WARNING! Does NOT move objects physics! Uses Sketchup's built in translation and makes it a little simpler to use. move(position, object) position - a 3D point to where you want to move the object object - the entity you want to move Examples: object=Sketchup.active_model.entities1 #an entity in model move(0,0,0,object) move(0,100,0) #with no object specified it will move the current object Scale WARNING! Does NOT scale objects physics! Uses Sketchup's built in scaling and makes it simpler to use. scale(s, object) s - determins by what muliplyer you want the object to grow, 2x makes it 2 times bigger object - the entity you want to scale Examples: object=Sketchup.active_model.entities1 #an entity in model scale(2,object) #2x bigger scale(1,object) #stays the same scale(10) #with no object specified it will scale the current object Rotate WARNING! Does NOT rotate objects physics! Uses Sketchup's built in rotation and makes it simpler to use. rotate(angle, axis, center_point, object) angle - determines the angle of rotation, an integer input will be asumed as degrees and a decimal input will be taken as radians axis - the axis on wich you want to make the rotation, the input can be "R","G","B"(for red, green, and blue axis) or you can input a vector as 0,0,1 center_point - center point of rotation, you may want to rotate the object on its own axis or around another object object - the entity you want to move Examples: object=Sketchup.active_model.entities1 #an entity in model rotate(45, "B", 0,0,0, object) #will rotate object by 45 degrees, on the blue axis, around the model center point 0,0,0 rotate(45) #with only angle input it will rotate the current object on the blue axis, around its own center point rotate(45, "B", 0,0,0) rotate(45, "B", nil, object) '''#if you don't specify center_point it will be taken from the object '''rotate(1.57, "R") #in this case we used redians for angle, and red axis for rotation rotate(1.57) rotate(1.57, 0,0,1) #axis input as vector EntityByName Will search entities(groups and components) by name, and return the handle for them. entityByName(entity_name, entity) entity_name - name of group/component you are looking for, input can be a single string or and array of strings(and it will return a single entity or an array of entities) entity - by default the function will search the entire model for entities, but you can also search within specific entities determined by this variable Examples: object=Sketchup.active_model.entities1 #an entity in model result=entityByName("target") #will find first entity named target and return it as the result result=entityByName("tar1","tar2","tar3") #will find all these entities, and return them as an array result=entityByName("target") #and this will find all entities named "target", and also return them as an array result=entityByName("box", object) #before we were searching in the model, now we search in the object DeepRay Uses Sketchup's built in raytest, and uses it for penetrating raytesting, and returns an array of results. deepRay(point, vector, depth) point - the starting 3D point of raytest vector - the vector/direction of raytest depth - how deep the ray should go(number of objects) return: it will return an array of arrays, each sub-array for the coresponding object Examples: point=0,0,0 vector=0,0,1 result=deepRay(point,vector,0) #at depth 0 it will just return an empty list/array result=deepRay(point,vector,2) #it will penetrate the first object to find another, and return an array #result structure: [first_object,second_object,third_object,...] #first_object: entity, raytest_result first_object=result0 #result for the first target it hit second_object=result1 hit_point=first_object0 #3D point where the object was hit entity=first_object1 #entity handle of the object raytest_result=first_object2 #the actual result of raytest RandVector Will offset the input vector randomly by a small degree determined by accuracy. Intended for gun inaccuracy simulation. randVector(vector, accuracy) vector - input vector to be offset accuracy - range from 0 to 100, percentage of accuracy(0 worst, 100 best) Examples: vector=1,0,0 new_vector=randVector(vector, 50) #will return a new vector with random offset new_vector=randVector(vector, 100) new_vector=randVector(vector, 0) Category:LazyScript